package cn.dankal.flyaudio.activity.detail

import android.os.Bundle
import cn.dankal.basiclib.protocol.MainProtocol
import cn.dankal.basiclib.util.WebViewUtil
import cn.dankal.business.Constants
import cn.dankal.business.pojo.CommentBean
import cn.dankal.business.pojo.InfoBean
import cn.dankal.business.pojo.ReasonBean
import cn.dankal.flyaudio.R
import cn.dankal.flyaudio.information.detail.InformationPostDetailActivity
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import kotlinx.android.synthetic.main.activity_infomation.*
import kotlinx.android.synthetic.main.layout_bottom_input_commend.*

/**
 * 资讯详情
 */
@Route(path = MainProtocol.INFO_DETAIL)
class InformationDetailActivity : InformationPostDetailActivity() {
    @Autowired(name = Constants.UUID)
    @JvmField
    var uuid:String?=null

    lateinit var infobean:InfoBean

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

    }

    override fun initComponents() {
        ARouter.getInstance().inject(this)
        addSingleTitleBar("资讯详情")
        super.initComponents()
        mPresenter.info_detail(uuid)
        initData(uuid)
    }

    override fun onInfoDetailResult(infoBean: InfoBean?) {
        infoBean?.apply {
            infobean= infoBean
            tv_info_title.text=title
            tv_time.text=createTime
            tv_comment_count.text=commentNumber
            tv_view_count.text=lookNumber
            WebViewUtil.initWebViewSettings(wb_conntent, this@InformationDetailActivity)
            wb_conntent.webViewClient=WebViewUtil.MyWebViewClient()
            WebViewUtil.loadData(wb_conntent,content)
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.activity_infomation
    }

    override fun onInnerCommentClick(name: String?, comment_id: String?, userId: String?, commentPosition:Int) {
        super.onInnerCommentClick(name, comment_id, userId,commentPosition)
        et_content.hint="@$name"
    }

    override fun onCommentResult(reasonBean: ReasonBean?,commemt:CommentBean) {
        super.onCommentResult(reasonBean,commemt)
        et_content.hint="写下您的评论"
        et_content.setText("")

    }

}
